package com.goodving.guli.bt.utils;

import android.content.Context;
import android.text.format.DateFormat;

import com.goodving.guli.R;
import com.goodving.guli.bt.Utils;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.utility.C1481u;
import com.goodving.guli.utility.Constants;
import com.goodving.guli.view.C0804t;
import com.goodving.guli.view.C3657a;
import com.goodving.guli.view.C4220a;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * Created by john on 2015/12/1.
 */
public class C0893f {
    public static final int f4480a = 24;
    public static final int f4481b = 60;
    public static final int f4482c = 1440;
    private static final boolean f4483d = false;
    private static final String f4484e = "TimeUtils";

    public static CharSequence m9084a(Context context, int i, int i2) {
        String[] e = C0893f.m9095e(i);
        C0804t.m8825a(context, 1.33f);
        if (e[0].equals(Constants.VIA_RESULT_SUCCESS)) {
            return context.getString(R.string.time_format_min, new Object[]{e[1]});
        }
        return context.getString(R.string.time_format_hour_min, new Object[]{e[0], e[1]});
    }

    public static String m9085a(int i) {
        Date date = new Date();
        GregorianCalendar gregorianCalendar = new GregorianCalendar();
        gregorianCalendar.set(GregorianCalendar.HOUR_OF_DAY, i / f4481b);
        gregorianCalendar.set(GregorianCalendar.MINUTE, i % f4481b);
        date.setTime(gregorianCalendar.getTimeInMillis());
        return C0893f.m9088a(date);
    }

    public static String m9086a(Context context, int i) {
        if (C0893f.m9095e(i)[0].equals(Constants.VIA_RESULT_SUCCESS)) {
            return context.getString(R.string.time_format_min, new Object[]{C0893f.m9095e(i)[1]});
        }
        return context.getString(R.string.time_format_hour_min, new Object[]{C0893f.m9095e(i)[0], C0893f.m9095e(i)[1]});
    }

    public static String m9087a(Boolean bool, long j) {
        Context a = C1481u.getContext();
        String str = bool.booleanValue() ? "yyyy-MM-dd " : "MM-dd ";
        return !DateFormat.is24HourFormat(a) ? C0893f.m9092c(new Date(j)) ? str + a.getString(R.string.detial_ampm_format) : str + a.getString(R.string.ampm_format) : str + "HH:mm";
    }

    public static String m9088a(Date date) {
        return C0893f.m9091b(date);
    }

    public static String m9089b(int i) {
        String[] c = C0893f.m9093c(i);
        return c[0] + C4220a.ci + c[1];
    }

    public static String m9090b(Context context, int i) {
        String[] d = C0893f.m9094d(i);
        return context.getString(R.string.time_format_hour_min, new Object[]{d[0], d[1]});
    }

    public static String m9091b(Date date) {
        Context a = C1481u.getContext();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
        GuliLog.tracePrintInfo(f4484e, "dateFormat.format(date)24\u65f6\u5236: " + simpleDateFormat.format(date));
        if (!DateFormat.is24HourFormat(a)) {
            if (C0893f.m9092c(date)) {
                simpleDateFormat.applyPattern(a.getString(R.string.detial_ampm_format));
                GuliLog.tracePrintInfo(f4484e, "dateFormat.format(date)\u51cc\u6668: " + simpleDateFormat.format(date));
            } else {
                simpleDateFormat.applyPattern(a.getString(R.string.ampm_format));
                GuliLog.tracePrintInfo(f4484e, "dateFormat.format(date)\u4e0a\u5348: " + simpleDateFormat.format(date));
            }
        }
        return simpleDateFormat.format(date);
    }

    public static boolean m9092c(Date date) {
        String format = new SimpleDateFormat("HH:mm").format(date);
        return (Integer.parseInt(new StringBuilder().append(C3657a.f18328f).append(format.charAt(1)).toString()) >= 6 || Integer.parseInt(C3657a.f18328f + format.charAt(0)) != 0 || Utils.m8087m()) ? f4483d : true;
    }

    public static String[] m9093c(int i) {
        if (i < 0) {
            i += f4482c;
        }
        String[] strArr = new String[]{String.valueOf(i / f4481b), String.valueOf(i % f4481b)};
        if (i / f4481b < 10) {
            strArr[0] = Constants.VIA_RESULT_SUCCESS + strArr[0];
        }
        if ((i % f4481b) < 10) {
            strArr[1] = Constants.VIA_RESULT_SUCCESS + strArr[1];
        }
        return strArr;
    }

    public static String[] m9094d(int i) {
        String[] strArr = new String[]{String.valueOf(i / f4481b), String.valueOf(i % f4481b)};
        if (i % f4481b < 10) {
            strArr[1] = Constants.VIA_RESULT_SUCCESS + strArr[1];
        }
        return strArr;
    }

    public static String[] m9095e(int i) {
        String[] strArr = new String[]{String.valueOf(i / f4481b), String.valueOf(i % f4481b)};
        if (i / f4481b > 0 && (i / f4481b) < 10) {
            strArr[1] = Constants.VIA_RESULT_SUCCESS + strArr[1];
        }
        return strArr;
    }
}
